home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DDJMAG / DDJ9203.ZIP / OOPASM.ASC < prev    next >
Text File  |  1992-01-24  |  26KB  |  694 lines

  1. _AN OBJECT-ORIENTED ASSEMBLY LANGUAGE MACRO LIBRARY_
  2. by Donald J. McSwain
  3.  
  4.  
  5. [LISTING ONE]
  6.  
  7. Macro File: objects.mac
  8.  
  9. COMMENT % ===============================================================
  10. Sets up stack, SI with object pointer, DX with message number, and calls
  11. sendMsg procedure.
  12. Passed: Obj - Name of receiving object; Msg - Message number
  13. =========================================================================%
  14. send    MACRO       Obj,Msg,ArgList
  15.         pushArgs    ArgList             ;Push arguments onto stack
  16.         IFIDN       <Obj>,<Self>        ;If object is Self
  17.         mov         si,Wptr[Self]       ;Get object ptr from it
  18.         ELSE
  19.         IFDIF       <Obj>,<si>          ;If object ptr not in SI
  20.         lea         si,Obj              ;Load SI with ptr to object
  21.         ENDIF
  22.         ENDIF
  23.  
  24.         IFDIF       <Msg>,<dx>          ;If msg number not in DX
  25.         mov         dx,Msg              ;Put it in DX
  26.         ENDIF
  27.  
  28.         call        sendMsg             ;Send message
  29.         IFNB        <ArgList>           ;If arguments
  30.         X       =   0                   ;Init stack depth counter
  31.         IRP         Arg,<ArgList>       ;For every arg on stack
  32.         X       =   X+2                 ;Increment depth counter
  33.         ENDM
  34.         add         sp,X                ;Reset stack pointer
  35.         ENDIF
  36.         ENDM
  37.  
  38. COMMENT % ===============================================================
  39. Pushes up to ten arguments onto the stack.
  40. =========================================================================%
  41. pushArgs    MACRO      A0,A1,A2,A3,A4,A5,A6,A7,A8,A9
  42.     IFB                <A0>                     ;If no more arguments
  43.     EXITM                                       ;Exit macro
  44.     ENDIF
  45.  
  46.     IFIDN              <A0>,<ax>                ;If arg in AX
  47.     push               ax                       ;Push AX
  48.     ELSE
  49.     IFIDN              <A0>,<bx>                ;If arg in BX
  50.     push               bx                       ;Push BX
  51.     ELSE
  52.     IFIDN              <A0>,<cx>                ;If arg in CX
  53.     push               cx                       ;Push CX
  54.     ELSE
  55.     IFIDN              <A0>,<dx>                ;If arg in DX
  56.     push               dx                       ;Push DX
  57.     ELSE
  58.     mov                bx,A0                    ;Else move into BX
  59.     push               bx                       ;Push BX
  60.     ENDIF
  61.     ENDIF
  62.     ENDIF
  63.     ENDIF
  64.     pushArgs           A1,A2,A3,A4,A5,A6,A7,A8,A9
  65.     ENDM
  66.  
  67. COMMENT %  =============================================================
  68. Finds the specified message for specified object.
  69. Passed: Msg - Message number; Obj - Addr ptr to object structure
  70. Passes: si - Pointer to combined method pointer
  71. =========================================================================%
  72. findMsg MACRO   Obj,Msg,Lbl
  73.         LOCAL   fdmg1,fdmg2
  74.         IFDIF       <Obj>,<si>      ;If object ptr is not in SI
  75.         mov         si,Obj          ;Put it there
  76.         ENDIF
  77.         mov         di,Wptr[si].Instances   
  78.                                     ;Addr of msg tbl end
  79.         mov         si,Wptr[si].Messages
  80.                                     ;Addr of msg tbl beginning 
  81. fdmg1: lodsb                        ;Fetch msg number
  82.        eq           al,Msg,fdmg2    ;Exit if message is found
  83.        add          si,2            ;Else point to next message
  84.        cmp          si,di           ;More messages?
  85.        jb           fdmg1           ;If so continue search
  86.  
  87.        IFNB         <Lbl>           ;If label provided
  88.        jmp          Lbl             ;Jump to it upon failure
  89.        ENDIF
  90. fdmg2:
  91.        ENDM
  92.  
  93. Source File: objects.asm
  94.     PUBLIC  sendMsg
  95. COMMENT % ===================================================================
  96. Sends the specified object the given message. This causes the execution of 
  97. the combined message for the object.
  98. Passed: dx - Message number; si - Combined method ptr
  99. =============================================================================%
  100. sendMsg PROC    NEAR
  101.         findMsg          si,dl,smg2      ;Search for message
  102.         mov              si,Wptr[si]     ;Get method addr
  103.         mov              cx,Wptr[si]     ;Get method count
  104. smg1:   add              si,2            ;Point to method
  105.         pushData         <cx,si>         ;Save loop cnt, addr ptr
  106.         call             Wptr[si]        ;Execute method
  107.         popData          <si,cx>         ;Restore addr ptr, loop cnt
  108.         loop             smg1            ;Loop
  109. smg2:   ret
  110. sendMsg ENDP
  111.  
  112.  
  113. [LISTING TWO]
  114.  
  115.  
  116. Include File: objects.inc
  117.  
  118. COMMENT % ==================================================================
  119. Data structure used to hold pointers to an object's ancestors, messages, and
  120. instance variables.
  121. ===========================================================================%
  122. _Object STRUC
  123.     Objects     DW  Nil
  124.     Messages    DW  Nil
  125.     Instances   DW  Nil
  126. _Object ENDS
  127.  
  128. Macro File: objects.mac
  129.  
  130. COMMENT % ===================================================================
  131. Defines an object.
  132. Passed: Obj - Object name; Objs - Ancestor list; Instances - Instance 
  133. variable list; Messages - Message list
  134. =============================================================================%
  135. defObj  MACRO   Obj,Objs,Instances,Messages
  136.         LOCAL   ObjTbl,MsgTbl,InstTbl
  137.  
  138.         ObjTbl      LABEL   WORD
  139.         objsDef     Obj,<Objs>
  140.  
  141.         MsgTbl      LABEL   WORD
  142.         msgsDef     Obj,<Messages>
  143.         InstTbl     LABEL   WORD
  144.         instDef     <Instances>
  145.         ALIGN   2
  146.         PUBLIC  Obj
  147.         Obj _Object     <ObjTbl,MsgTbl,InstTbl>
  148.         ENDM
  149.  
  150. COMMENT % ===================================================================
  151. Defines objects.
  152. Passed: Obj - Object name; Objs - Ancestor list
  153. =============================================================================%
  154. objsDef MACRO   Obj,Objs
  155.         DW      Obj
  156.         IRP     Obj,<Objs>
  157.         DW      Obj
  158.         ENDM
  159.         ENDM
  160.  
  161. COMMENT % ====================================================================
  162. Defines messages.
  163. Passed: Obj - Object name; Messages - Message list
  164. =============================================================================%
  165. msgsDef MACRO   Obj,Messages
  166.         IRP     Msg,<Messages>
  167.         DB      Msg         ;Msg# identifies msg
  168.         IFNDEF  Obj&&Msg
  169.         DW      Nil         ;Obj has no local methods
  170.         ELSE
  171.         DW      Obj&&Msg        ;Obj has local methods
  172.         ENDIF
  173.         ENDM
  174.         ENDM
  175.  
  176. COMMENT % =================================================================== 
  177. Defines instances variables.
  178. Passed: Instances - Instance variable list
  179. =============================================================================%
  180. instDef MACRO   Instances
  181.         X       =      0
  182.         Y       =      0
  183.         IRP            Inst,<Instances>
  184.         defInst        Inst,%X,%Y
  185.         ENDM
  186.         ENDM
  187.  
  188. COMMENT % ====================================================================
  189. Defines an instance variable.
  190. Passed: Inst - Instance variable name; Cnt - Instance variable field number;
  191. Size - Size of instance variable
  192. =============================================================================%
  193. defInst MACRO   Inst,Cnt,Size
  194.         IFIDN       <Cnt>,<0>
  195.         X       =   X+1
  196.         ELSE
  197.         IFIDN       <Cnt>,<1>
  198.         X       =   X+1
  199.         Y       =   Inst
  200.         ELSE
  201.         X       =   0
  202.         defVar      Size,Inst
  203.         ENDIF
  204.         ENDIF
  205.         ENDM
  206.  
  207. COMMENT % ====================================================================
  208. Defines a data item.
  209. Passed: Size - Size of data in bytes; Value - Value of data item
  210. =============================================================================%
  211. defVar  MACRO   Size,Value
  212.         IFIDN       <Size>,<1>
  213.         DB          Value
  214.         ELSE
  215.         IFIDN       <Size>,<2>
  216.         DW          Value
  217.         ELSE
  218.         IFIDN       <Size>,<4>
  219.         DD          Value
  220.         ELSE
  221.         IFIDN       <Size>,<8>
  222.         DQ          Value
  223.         ELSE
  224.         IFIDN       <Size>,<10>
  225.         DT          Value
  226.         ENDIF
  227.         ENDIF
  228.         ENDIF
  229.         ENDIF
  230.         ENDIF
  231.         ENDM
  232.  
  233.  
  234.  
  235.  
  236. [LISTING THREE]
  237.  
  238. Include File: objects.inc
  239.  
  240. COMMENT % ==================================================================
  241. Data structure used to hold pointers to a message's Before, Primary, and
  242. After methods.
  243. ===========================================================================%
  244. _Message    STRUC
  245.     Before      DW  Nil
  246.     Primary     DW  Nil
  247.     After       DW  Nil
  248. _Message    ENDS
  249.  
  250. Macro File: objects.mac
  251.  
  252. COMMENT % ====================================================================
  253. Defines a message.
  254. Passed: Obj - Object name; Msg - Message name; Methods - Method list 
  255. =============================================================================%
  256. defMsg  MACRO   Obj,Msg,Methods
  257.         ALIGN   2
  258.         Obj&Msg _Message    <Methods>
  259.         ENDM    
  260.  
  261.  
  262.  
  263.  
  264. [LISTING FOUR]
  265.  
  266. Macro File: objects.mac
  267.  
  268. COMMENT % ====================================================================
  269. Sets us SI to point to object, and calls initObject procedure.
  270. =============================================================================%
  271. initObj     MACRO   Obj
  272.         lea         si,Obj          ;Pass object ptr
  273.         call        initObject      ;Find all ancestors
  274.         ENDM
  275.  
  276. Source File: objects.asm
  277.  
  278.     PUBLIC  initObject
  279. COMMENT % ====================================================================
  280. Initializes an object by flattening its inheritance lattice to create 
  281. combined methods for its messages.
  282. Passed: si - Addr ptr to object structure
  283. =============================================================================%
  284. initObject  PROC    NEAR
  285.           lea       di,Buffer           ;Get buffer addr
  286.           call      findAncestors       ;Find/Save all ancestors
  287.           call      evalMsgs            ;Evaluate messages
  288.           ret
  289. initObject  ENDP
  290.  
  291. COMMENT % ====================================================================
  292. Finds all of an object's ancestors and saves them for use by the message 
  293. evaluator.
  294. Passed: bx - Addr ptr to message table (end of object table); di - Addr ptr 
  295. to temporary object table; si - Addr ptr to object structure
  296. =============================================================================%
  297. findAncestors   PROC    NEAR
  298.         pushData        <bx,si>                  ;Save obj ptr
  299.         mov             bx,Wptr[si].Messages     ;Get addr ptr to msg tbl
  300.         mov             si,Wptr[si].Objects      ;Get addr of object tbl
  301.         movsw                                    ;Move obj ptr
  302. fas1:   eq              bx,si,fas2               ;Exit if end of tbl
  303.         push            si
  304.         mov             si,Wptr[si]              ;Get next object
  305.         call            findAncestors            ;Find others
  306.         pop             si
  307.         add             si,2
  308.         jmp             fas1                     ;More in tbl - Loop
  309. fas2:   mov             Wptr[di],Nil             ;Mark end of list
  310.         popData         <si,bx>                  ;Restore obj ptr
  311.         ret
  312. findAncestors   ENDP
  313.  
  314. COMMENT % ====================================================================
  315. Creates combined methods for all of an object's messages.
  316. Passed: si - Addr ptr to object structure
  317. =============================================================================%
  318. evalMsgs    PROC        NEAR
  319.         mov             bx,Wptr[si].Messages    ;Get addr of message tbl
  320.         mov             cx,Wptr[si].Instances   ;Get addr of instance tbl
  321. ems1:   mov             dl,Bptr[bx]             ;Get msg number
  322.         xor             dh,dh
  323.         call            combineMethods          ;Combine methods
  324.         add             bx,3                    ;Point to next tbl entry
  325.         neq             bx,cx,ems1              ;More in tbl? - loop
  326.         ret
  327. evalMsgs    ENDP
  328.  
  329. COMMENT % ==================================================================== 
  330. Combines methods for all included objects.
  331. Passed: dx - Message number; si - Addr ptr to object structure
  332. =============================================================================%
  333. combineMethods  PROC    NEAR
  334.        push             bx
  335.        mov              ?Compiled,Nil           ;Clear compiled flag
  336.        mov              bx,Wptr[CompileStart]   ;Get start of combined mthd
  337.        mov              Wptr[CompilePtr],bx ;Init location ptr
  338.        mov              di,Nil                  ;Zero count word
  339.        call             saveMethodAddr          ;Save value
  340.        call             saveBefores             ;Save Before methods
  341.        mov              bx,Primary              ;Select Primary method type
  342.        lea              di,Buffer               ;Get addr of tmp object tbl
  343.        mov              di,Wptr[di]             ;Get tbl entry
  344.        call             saveMethod              ;Save method
  345.        call             saveAfters              ;Save After methods
  346.        null             ?Compiled,cms1          ;Nothing compiled? - Exit
  347.        call             updatePtrs              ;Update message, location ptrs
  348. cms1:  pop              bx
  349.        ret
  350. combineMethods  ENDP
  351.  
  352. COMMENT % ====================================================================
  353. Updates the message and location pointers.
  354. Passed: dx - Message number; si - Addr ptr to object structure
  355. =============================================================================%
  356. updatePtrs  PROC        NEAR
  357.        push             si
  358.        findMsg          si,dl                   ;Find message
  359.        mov              di,Wptr[CompileStart]   ;Get ptr to combined method
  360.        mov              Wptr[si],di             ;Change message ptr
  361.  
  362.        mov              bx,Wptr[CompilePtr]     ;Get current compile location
  363.        mov              Wptr[CompileStart],bx   ;Reset start of combined mthd 
  364.        pop              si
  365.        ret
  366. updatePtrs  ENDP
  367.  
  368. COMMENT % ====================================================================
  369. Save the Before method type for the specified object.
  370. Passed: dx - Message number
  371. =============================================================================%
  372. saveBefores PROC    NEAR
  373.         push        si
  374.         mov         bx,Before       ;Select Before method type
  375.         lea         si,Buffer       ;Get addr of tmp object tbl
  376.         mov         di,Wptr[si]     ;Get tbl entry
  377. sbs1:   call        saveMethod      ;Save method
  378.         add         si,2            ;Point to next tbl entry
  379.         mov         di,Wptr[si]     ;Get next tbl entry
  380.         identity    di,sbs1         ;More in table? - loop
  381.         pop         si
  382.         ret
  383. saveBefores ENDP
  384.  
  385. COMMENT % ===================================================================
  386. Save the After method type for the specified object.
  387. Passed: dx - Message number
  388. =============================================================================%
  389. saveAfters  PROC    NEAR
  390.         pushData    <cx,si>
  391.         mov         bx,After        ;Select After method type
  392.         lea         si,Buffer       ;Get addr of tmp object tbl
  393.         mov         cx,si           ;Save addr of object tbl
  394. sas1:   mov         ax,Wptr[si]     ;Get tbl entry
  395.         null        ax,sas2         ;Null? - End of tbl, exit
  396.         add         si,2            ;Point to next tbl entry
  397.         jmp         sas1            ;Loop
  398. sas2:   sub         si,2            ;Point to previous tbl entry
  399.         mov         di,Wptr[si]     ;Get next tbl entry
  400.         call        saveMethod      ;Save method
  401.         neq         si,cx,sas2
  402.         popData     <si,cx>
  403.         ret
  404. saveAfters  ENDP
  405.  
  406. COMMENT % ====================================================================
  407. Save the specified method for specified object.
  408. Passed: bx-Method type; di-Addr ptr to object structure; dx-Message number
  409. =============================================================================%
  410. saveMethod  PROC    NEAR
  411.         pushData    <bx,di,si>
  412.         findMsg     di,dl,svm3      ;Find message
  413.         mov         di,Wptr[si]     ;Get method tbl addr ptr
  414.         null        di,svm3         ;Exit if no local methods
  415.         mov         di,Wptr[di+bx]  ;Get method addr ptr
  416.         null        di,svm3         ;Exit if no message
  417.         mov         bx,Wptr[CompileStart]   ;Get start of combined mthd
  418. svm1:   eq          bx,Wptr[CompilePtr],svm2
  419.         eq          di,Wptr[bx],svm3    ;Exit if duplicate method
  420.         add         bx,2            ;Point to next addr
  421.         jmp         svm1            ;Check next addr
  422. svm2:   call        saveMethodAddr  ;Save method addr
  423. svm3:   popData     <si,di,bx>
  424.         ret
  425. saveMethod  ENDP
  426.  
  427. COMMENT % ====================================================================
  428. Save value at current compile location, and increments location pointer.
  429. Passed: di - Value to store
  430. =============================================================================%
  431. saveMethodAddr  PROC    NEAR
  432.     mov                 ?Compiled,1         ;Set compiled flag
  433.     mov                 bx,Wptr[CompilePtr] ;Get ptr to combined mthd end
  434.     mov                 Wptr[bx],di         ;Save value
  435.     add                 bx,2                ;Point to next location
  436.     mov                 Wptr[CompilePtr],bx ;Reset location ptr 
  437.     mov                 bx,Wptr[CompileStart]   ;Get ptr mthd count
  438.     mov                 di,Wptr[bx]         ;Get mthd count
  439.     inc                 di                  ;Increments mthd count
  440.     mov                 Wptr[bx],di         ;Save value
  441.     ret
  442. saveMethodAddr  ENDP
  443.  
  444.  
  445.  
  446. [LISTING FIVE]
  447.  
  448. Macro File: objects.mac
  449.  
  450. COMMENT % ====================================================================
  451. Gets an object's instance variable.
  452. Passed: Dest- Destination register; Var - Instance variable name; 
  453. Obj - Source object 
  454. =============================================================================%
  455. getInst MACRO   Dest,Var,Obj
  456.         IFNB            <Obj>
  457.         IFIDN           <Obj>,<Self>
  458.         mov             si,WORD PTR[Self]
  459.         mov             si,WORD PTR[si].Instances
  460.         ELSE
  461.         IFIDN           <si>,<Obj>
  462.         mov             si,WORD PTR[si].Instances
  463.         ELSE
  464.         mov             si,Obj&.Instances
  465.         ENDIF
  466.         ENDIF
  467.         ENDIF
  468.         mov             Dest,[si+Var]
  469.         ENDM
  470.  
  471. COMMENT % ====================================================================
  472. Sets an object's instance variable.
  473. Passed: Var - Instance variable name; Source - Source register; Obj - Source 
  474. object; Size - Size of data
  475. =============================================================================%
  476. setInst       MACRO       Var,Source,Obj,Size
  477.               IFNB        <Obj>
  478.               IFIDN       <Obj>,<Self>
  479.               mov         si,WORD PTR[Self]
  480.               mov         si,WORD PTR[si].Instances
  481.               ELSE
  482.               mov         si,Obj&.Instances
  483.               ENDIF
  484.               ENDIF
  485.               setInst_     Var,Source,Size
  486.               ENDM
  487.  
  488. COMMENT % ====================================================================
  489. Assembles move instruction based on source register.
  490. =============================================================================%
  491. setInst_      MACRO        Var,Source,Size
  492.         IFIDN              <Source>,<al>
  493.         mov                BYTE PTR[si+Var],Source
  494.         ELSE
  495.         IFIDN              <Source>,<ah>
  496.         mov                BYTE PTR[si+Var],Source
  497.         ELSE
  498.         IFIDN              <Source>,<bl>
  499.         mov                BYTE PTR[si+Var],Source
  500.         ELSE
  501.         IFIDN              <Source>,<bh>
  502.         mov                BYTE PTR[si+Var],Source
  503.         ELSE
  504.         IFIDN              <Source>,<cl>
  505.         mov                BYTE PTR[si+Var],Source
  506.         ELSE
  507.         IFIDN              <Source>,<ch>
  508.         mov                BYTE PTR[si+Var],Source
  509.         ELSE
  510.         IFIDN              <Source>,<dl>
  511.         mov                BYTE PTR[si+Var],Source
  512.         ELSE
  513.         IFIDN              <Source>,<dh>
  514.         mov                BYTE PTR[si+Var],Source
  515.         ELSE
  516.         IFIDN              <Source>,<ax>
  517.         mov                WORD PTR[si+Var],Source
  518.         ELSE
  519.         IFIDN              <Source>,<bx>
  520.         mov                WORD PTR[si+Var],Source
  521.         ELSE
  522.         IFIDN              <Source>,<cx>
  523.         mov                WORD PTR[si+Var],Source
  524.         ELSE
  525.         IFIDN              <Source>,<dx>
  526.         mov                WORD PTR[si+Var],Source
  527.         ELSE
  528.         IFIDN              <Source>,<di>
  529.         mov                WORD PTR[si+Var],Source
  530.         ELSE
  531.         IFIDN              <Source>,<si>
  532.         mov                WORD PTR[si+Var],Source
  533.         ELSE
  534.         IFIDN              <Size>,<1>
  535.         mov                BYTE PTR[si+Var],Source
  536.         ELSE
  537.         IFIDN              <Size>,<2>
  538.         mov                WORD PTR[si+Var],Source
  539.         ENDIF
  540.         ENDIF
  541.         ENDIF
  542.         ENDIF
  543.         ENDIF
  544.         ENDIF
  545.         ENDIF
  546.         ENDIF
  547.         ENDIF
  548.         ENDIF
  549.         ENDIF
  550.         ENDIF
  551.         ENDIF
  552.         ENDIF
  553.         ENDIF
  554.         ENDIF
  555.         ENDM
  556.  
  557.  
  558.  
  559.  
  560.  
  561. [LISTING SIX]
  562.  
  563. Macro File: objects.mac
  564.  
  565. COMMENT % ====================================================================
  566. Gets an object's instance variable, but object is pointed to by one of 
  567. Self's instance variables.
  568. Passed: Dest- Destination register; Var - Instance variable name; 
  569. Obj - Source object instance variable
  570. =============================================================================%
  571. getInst$    MACRO   Dest,Var,Obj
  572.     mov             si,WORD PTR[Self]         
  573.     mov             si,WORD PTR[si].Instances 
  574.     mov             si,[si+Obj]               
  575.     mov             si,WORD PTR[si].Instances 
  576.     mov             Dest,[si+Var]             
  577.     ENDM
  578.  
  579. COMMENT % ====================================================================
  580. Sets an object's instance variable, but object is pointed to by one of 
  581. Self's instance variables.
  582. Passed: Var - Instance variable name; Source - Source register; Obj - Source 
  583. object instance variable; Size - Size of data
  584. =============================================================================%
  585. setInst$    MACRO   Var,Source,Obj,Size
  586.     mov             si,WORD PTR[Self]          
  587.     mov             si,WORD PTR[si].Instances  
  588.     mov             si,[si+Obj]                
  589.     mov             si,WORD PTR[si].Instances  
  590.     setInst_        Var,Source,Size        
  591.     ENDM
  592.  
  593.  
  594.  
  595.  
  596. [Example 1]
  597.  
  598. send Screen,Refresh,DoubleBdr  ;Send Screen a Refresh msg
  599. send Self,Read                 ;Send Self a Read msg
  600. send Self,<WORD PTR[bx]>       ;Send Self msg pointed to by
  601.                                ;  BX register
  602.  
  603.  
  604. [Example 2]
  605.  
  606. defObj Window,\     ;Define Window object
  607.        <>,\         ;As a base object
  608.        <>,\         ;With no inst vars
  609.        <Refresh>    ;Responds to Refresh msg
  610.  
  611. defObj Border,\     ;Define Border object
  612.        <>,\         ;As a base object
  613.        <>,\         ;With no inst vars
  614.        <Refresh>    ;Responds to Refresh msg
  615.  
  616. defObj Screen,\     ;Define Screen object
  617.        <Window,Border>,\  ;As a derived object
  618.        <Row1,1,1,\  ;With these inst vars
  619.        Col1,1,0,\
  620.        Row2,1,23,\
  621.        Col2,1,79,\
  622.        Color,1,34h,\
  623.        BdrColor,1,30h,\
  624.        MemSeg,2,Nil>,\
  625.        <Refresh>     ;Responds to Refresh msg
  626.  
  627.  
  628.  
  629. [Example 3]
  630.  
  631. defMsg Window,\     ;Define for Window object
  632.        Refresh,\    ;The Refresh msg
  633.        <clrWin,,>   ;To clear window 
  634.  
  635. defMsg Border,\     ;Define for Border object
  636.        Refresh,\    ;The Refresh msg
  637.        <,,drawBdr>  ;To draw border
  638.  
  639. defMsg Screen,\     ;Define for Screen object
  640.        Refresh,\    ;The Refresh msg
  641.        <,drawBackDrop,drawLabel>
  642.                     ;To draw back drop and label
  643.  
  644.  
  645. [Example 4]
  646.  
  647. defMsg Label,\        ;Define for Label object
  648.        Refresh,\      ;The Refresh msg
  649.        <,,drawLabel>  ;To draw label
  650.  
  651. defObj label,\        ;Define Label object
  652.        <>,\           ;As a base object
  653.        <>,\           ;With no inst vars
  654.        <Refresh>      ;Responds to Refresh msg
  655.  
  656. defMsg Screen,\        ;Define for Screen object
  657.        Refresh,\       ;The Refresh msg
  658.        <,drawBackDrop,> ;To draw back drop 
  659.  
  660. defObj Screen,\        ;Define Screen object
  661.        <Window,Border,Label>,\      
  662.                        ;As a derived object
  663.        <Row1,1,1,\     ;With these inst vars
  664.        Col1,1,0,\
  665.        Row2,1,23,\
  666.        Col2,1,79,\
  667.        Color,1,34h,\
  668.        BdrColor,1,30h,\
  669.        MemSeg,2,Nil>,\
  670.        <Refresh>         ;Responds to Refresh msg
  671.  
  672.  
  673.  
  674.  
  675. [Example 5]
  676.  
  677. initObj Screen   ;Combine methods for Screen
  678.  
  679.  
  680. [Example 6]
  681.  
  682. getInst bl,Color,Screen  ;Fetch Screen color
  683. setInst BdrColor,bl      ;Copy it to BdrColor
  684. setInst Color,bl,Self    ;And Self's color
  685.  
  686.  
  687.  
  688. [Example 7]
  689.  
  690. getInst$ bl,Color,Master  ;Fetch color from object
  691.                           ; pointed to by Master
  692. setInst  Color,bl,Self    ;Copy it to Self's color
  693.  
  694.